package com.happyfamily.springboot.crowdsourcingplatform.controller.weng;


import com.happyfamily.springboot.crowdsourcingplatform.annotation.OperationLogDetail;
import com.happyfamily.springboot.crowdsourcingplatform.enums.OperationType;
import com.happyfamily.springboot.crowdsourcingplatform.enums.OperationUnit;
import com.happyfamily.springboot.crowdsourcingplatform.service.weng.ProcessService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api-back/worm")
@Slf4j

public class WormController
{
	@Autowired
	ProcessService processService;


	@GetMapping("spiter")
	@PreAuthorize("hasAuthority('back:news:add')")
	@ApiOperation(value = "爬取搜狐互联网最新资讯", notes = "爬取搜狐互联网最新资讯", httpMethod = "GET", response = String.class)
	@OperationLogDetail(detail = "爬取最新资讯", level = 3, operationUnit = OperationUnit.ADMIN, operationType = OperationType.INSERT)
	public String spiterGet()
	{
		processService.process();
		return "SUCCESS";
	}

	@GetMapping("spiterToIndustry")
	@PreAuthorize("hasAuthority('back:industry:add')")
	@ApiOperation(value = "爬取各行业最新动态", notes = "爬取各行业最新动态", httpMethod = "GET", response = String.class)
	@OperationLogDetail(detail = "爬取行业最新动态", level = 3, operationUnit = OperationUnit.ADMIN, operationType = OperationType.INSERT)
	public String spiterToIndustryGet(String industry)
	{
		processService.processToIndustry(industry);
		return "SUCCESS";
	}
}
